package com.gjy.gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-01-24 14:55:45
 */
@EnableScheduling
@Component
public class RouteRefreshSchedule {

    private final RouteLocator routeLocator;

    public RouteRefreshSchedule(RouteLocator routeLocator) {
        this.routeLocator = routeLocator;
    }

    @Scheduled(cron = "0/30 * * * * ?")
    public void refreshRoute() {
        routeLocator.getRoutes().subscribe(route -> {
        });
    }
}
